package hy.service;

import hy.beans.Item;
import hy.beans.Order;
import hy.dao.OrderDao;
import hy.dao.StoreDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderService {
    @Autowired
	private OrderDao orderDao;
	@Autowired
	private StoreDao storeDao;

	@Transactional//使用Jta事务管理器
	public void processOrder(Order o) throws Exception {
		orderDao.saveOrder(o);
		for(Item i:o.getItems()){
			orderDao.saveItems(i);
		}

		for(Item i:o.getItems()){
			storeDao.reduceNum(i);
		}
		int a=1/0;
	}
}